home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Skunkware 5
/
Skunkware 5.iso
/
src
/
X11
/
xsw
/
sysinfo.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-05-09
|
13KB
|
307 lines
/*
* @(#) sysinfo.c 12.1 95/05/09 SCOINC
*/
/***************************************************************************
*
* Copyright (c) 1990-1993 The Santa Cruz Operation, Inc.
*
* All rights reserved. No part of this program or publication may be
* reproduced, transmitted, transcribed, stored in a retrieval system,
* or translated into any language or computer language, in any form or
* by any means, electronic, mechanical, magnetic, optical, chemical,
* biological, or otherwise, without the prior written permission of:
*
* The Santa Cruz Operation , Inc. (408) 425-7222
* 400 Encinal St., Santa Cruz, California 95060 USA
*
**************************************************************************/
/*
* Modification History
*
* S002, 27-May-93, rickra
* Added support for pixmaps.
*
* S001, 30-Sep-92, rickra
* Added support for seperate windows.
*
* S000, 30-Sep-92, rickra
* Added copyright and modification history
* Changed window header to expand to the right for resize
*/
/*+-------------------------------------------------------------------------
sysinfo.c - XSW sysinfo/minfo display handler
wht@n4hgf.Mt-Park.GA.US
Defined functions:
draw_Sysinfo_literals(x,y)
update_Sysinfo()
--------------------------------------------------------------------------*/
/*+:EDITS:*/
/*:09-25-1990-05:11-wht@n4hgf-release heh-heh x0.22 preliminary */
/*:09-20-1990-00:09-wht@n4hgf-scales, sysinfo/minfo, bootinfo working */
/*:09-15-1990-14:47-wht-creation */
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Intrinsic.h>
#include <X11/Shell.h>
#include <Xm/Xm.h>
#include <Xm/MainW.h>
#include <Xm/DrawingA.h>
#include "include/unixincs.h"
#include "include/buttons.h"
#include "include/xsw.h"
extern struct NetworkXswStruct *current_server;
int sysinfo_tlx;
int sysinfo_tly;
/*+-------------------------------------------------------------------------
update_Sysinfo()
--------------------------------------------------------------------------*/
void
update_Sysinfo (SP)
struct NetworkXswStruct *SP;
{
Window window = SP -> SEPERATE_WINDOWS_LIST[BUTTON_sysinfo].window;
Display *display = SP -> SEPERATE_WINDOWS_LIST[BUTTON_sysinfo].display;
GC gc = SP -> SEPERATE_WINDOWS_LIST[BUTTON_sysinfo].gc;
XWindowAttributes DrawAreaXYWH = SP -> SEPERATE_WINDOWS_LIST[BUTTON_sysinfo].DrawAreaXYWH;
Pixmap pixmap = SP -> SEPERATE_WINDOWS_LIST[BUTTON_sysinfo].pixmap;
register int x, y;
int fheight = FHEIGHT;
/*
if (DrawAreaXYWH.height < (sysinfo_tly + (fheight * 2)))
return;
*/
y = sysinfo_tly + fheight;
x = sysinfo_tlx + Sysinfo1_TLX;
disp_info_long (window, display, gc, DrawAreaXYWH, pixmap, x, y, "bread ", "%7ld", sysidelta (bread));
y += fheight;
disp_info_long (window, display, gc, DrawAreaXYWH, pixmap, x, y, "bwrite ", "%7ld", sysidelta (bwrite));
y += fheight;
disp_info_long (window, display, gc, DrawAreaXYWH, pixmap, x, y, "lread ", "%7ld", sysidelta (lread));
y += fheight;
disp_info_long (window, display, gc, DrawAreaXYWH, pixmap, x, y, "lwrite ", "%7ld", sysidelta (lwrite));
y += fheight;
disp_info_long (window, display, gc, DrawAreaXYWH, pixmap, x, y, "phread ", "%7ld", sysidelta (phread));
y += fheight;
disp_info_long (window, display, gc, DrawAreaXYWH, pixmap, x, y, "phwrite ", "%7ld", sysidelta (phwrite));
y += fheight;
disp_info_long (window, display, gc, DrawAreaXYWH, pixmap, x, y, "swapin ", "%7ld", sysidelta (swapin));
y += fheight;
disp_info_long (window, display, gc, DrawAreaXYWH, pixmap, x, y, "swapout ", "%7ld", sysidelta (swapout));
y += fheight;
disp_info_long (window, display, gc, DrawAreaXYWH, pixmap, x, y, "bswapin ", "%7ld", sysidelta (bswapin));
y += fheight;
disp_info_long (window, display, gc, DrawAreaXYWH, pixmap, x, y, "bswapout ", "%7ld", sysidelta (bswapout));
y += fheight;
disp_info_long (window, display, gc, DrawAreaXYWH, pixmap, x, y, "iget ", "%7ld", sysidelta (iget));
y += fheight;
disp_info_long (window, display, gc, DrawAreaXYWH, pixmap, x, y, "namei ", "%7ld", sysidelta (namei));
y += fheight;
disp_info_long (window, display, gc, DrawAreaXYWH, pixmap, x, y, "dirblk ", "%7ld", sysidelta (dirblk));
y += fheight;
y = sysinfo_tly + fheight;
x = sysinfo_tlx + Sysinfo2_TLX;
disp_info_long (window, display, gc, DrawAreaXYWH, pixmap, x, y, "readch ", "%7ld", sysidelta (readch));
y += fheight;
disp_info_long (window, display, gc, DrawAreaXYWH, pixmap, x, y, "writch ", "%7ld", sysidelta (writech));
y += fheight;
disp_info_long (window, display, gc, DrawAreaXYWH, pixmap, x, y, "rawch ", "%7ld", sysidelta (rawch));
y += fheight;
disp_info_long (window, display, gc, DrawAreaXYWH, pixmap, x, y, "canch ", "%7ld", sysidelta (canch));
y += fheight;
disp_info_long (window, display, gc, DrawAreaXYWH, pixmap, x, y, "outch ", "%7ld", sysidelta (outch));
y += fheight;
disp_info_long (window, display, gc, DrawAreaXYWH, pixmap, x, y, "msg ", "%7ld", sysidelta (msg));
y += fheight;
disp_info_long (window, display, gc, DrawAreaXYWH, pixmap, x, y, "sema ", "%7ld", sysidelta (sema));
y += fheight;
disp_static_long (window, display, gc, DrawAreaXYWH, pixmap, x, y, "maxmem ", "%6ldk", (long) *current_server -> my_maxmem * NBPP / 1024);
y += fheight;
disp_info_long (window, display, gc, DrawAreaXYWH, pixmap, x, y, "frmem ", "%6ldk", (long) *current_server -> my_freemem * NBPP / 1024);
y += fheight;
disp_info_int (window, display, gc, DrawAreaXYWH, x, y, pixmap, "mem used", "%6d%%",
100 - (int) ((*current_server -> my_freemem * 100) / *current_server -> my_maxmem));
y += fheight;
disp_static_int (window, display, gc, DrawAreaXYWH, pixmap, x, y, "nswap ", "%6ldk", current_server -> my_nswap);
y += fheight;
disp_info_long (window, display, gc, DrawAreaXYWH, pixmap, x, y, "frswp ", "%6ldk", current_server -> my_minfo -> freeswap * NBPSCTR / 1024);
y += fheight;
disp_info_int (window, display, gc, DrawAreaXYWH, x, y, pixmap, "swp used", "%6d%%",
100 - (int) ((current_server -> my_minfo -> freeswap * NBPSCTR / 1024) * 100) / current_server -> my_nswap);
y += fheight;
disp_info_int (window, display, gc, DrawAreaXYWH, x, y, pixmap, "availswp", "%6dk",
(int) *current_server -> my_availsmem * NBPP / 1024);
y += fheight;
y = sysinfo_tly + fheight;
x = sysinfo_tlx + Sysinfo3_TLX;
disp_info_long (window, display, gc, DrawAreaXYWH, pixmap, x, y, "pswitch ", "%5ld", sysidelta (pswitch));
y += fheight;
disp_info_long (window, display, gc, DrawAreaXYWH, pixmap, x, y, "syscall ", "%5ld", sysidelta (syscall));
y += fheight;
disp_info_long (window, display, gc, DrawAreaXYWH, pixmap, x, y, "sysread ", "%5ld", sysidelta (sysread));
y += fheight;
disp_info_long (window, display, gc, DrawAreaXYWH, pixmap, x, y, "syswrit ", "%5ld", sysidelta (syswrite));
y += fheight;
disp_info_long (window, display, gc, DrawAreaXYWH, pixmap, x, y, "sysfork ", "%5ld", sysidelta (sysfork));
y += fheight;
disp_info_long (window, display, gc, DrawAreaXYWH, pixmap, x, y, "sysexec ", "%5ld", sysidelta (sysexec));
y += fheight;
y += fheight;
disp_info_long (window, display, gc, DrawAreaXYWH, pixmap, x, y, "runque ", "%5ld", sysidelta (runque));
y += fheight;
disp_info_long (window, display, gc, DrawAreaXYWH, pixmap, x, y, "runocc ", "%5ld", sysidelta (runocc));
y += fheight;
disp_info_long (window, display, gc, DrawAreaXYWH, pixmap, x, y, "swpque ", "%5ld", sysidelta (swpque));
y += fheight;
disp_info_long (window, display, gc, DrawAreaXYWH, pixmap, x, y, "swpocc ", "%5ld", sysidelta (swpocc));
y += fheight;
y = sysinfo_tly + fheight;
x = sysinfo_tlx + Sysinfo4_TLX;
disp_info_long (window, display, gc, DrawAreaXYWH, pixmap, x, y, "vfault ", "%3ld", midelta (vfault));
y += fheight;
disp_info_long (window, display, gc, DrawAreaXYWH, pixmap, x, y, "demand ", "%3ld", midelta (demand));
y += fheight;
disp_info_long (window, display, gc, DrawAreaXYWH, pixmap, x, y, "pfault ", "%3ld", midelta (pfault));
y += fheight;
disp_info_long (window, display, gc, DrawAreaXYWH, pixmap, x, y, "cw ", "%3ld", midelta (cw));
y += fheight;
disp_info_long (window, display, gc, DrawAreaXYWH, pixmap, x, y, "steal ", "%3ld", midelta (steal));
y += fheight;
disp_info_long (window, display, gc, DrawAreaXYWH, pixmap, x, y, "frdpgs ", "%3ld", midelta (freedpgs));
y += fheight;
#if defined(SVR32)
disp_info_long (window, display, gc, DrawAreaXYWH, pixmap, x, y, "vfpg ", "%3ld", midelta (vfpg));
y += fheight;
disp_info_long (window, display, gc, DrawAreaXYWH, pixmap, x, y, "sfpg ", "%3ld", midelta (sfpg));
y += fheight;
disp_info_long (window, display, gc, DrawAreaXYWH, pixmap, x, y, "vspg ", "%3ld", midelta (vspg));
y += fheight;
disp_info_long (window, display, gc, DrawAreaXYWH, pixmap, x, y, "sspg ", "%3ld", midelta (sspg));
y += fheight;
disp_info_long (window, display, gc, DrawAreaXYWH, pixmap, x, y, "pnpfault", "%3ld", sysidelta (pnpfault));
y += fheight;
disp_info_long (window, display, gc, DrawAreaXYWH, pixmap, x, y, "wrtfault", "%3ld", sysidelta (wrtfault));
y += fheight;
#endif
y = sysinfo_tly + fheight;
x = sysinfo_tlx + Sysinfo5_TLX;
disp_info_long (window, display, gc, DrawAreaXYWH, pixmap, x, y, "unmodsw ", "%3ld", midelta (unmodsw));
y += fheight;
disp_info_long (window, display, gc, DrawAreaXYWH, pixmap, x, y, "unmodfl ", "%3ld", midelta (unmodfl));
y += fheight;
#if defined(SVR32)
disp_info_long (window, display, gc, DrawAreaXYWH, pixmap, x, y, "psoutok ", "%3ld", midelta (psoutok));
y += fheight;
disp_info_long (window, display, gc, DrawAreaXYWH, pixmap, x, y, "psinfai ", "%3ld", midelta (psinfail));
y += fheight;
disp_info_long (window, display, gc, DrawAreaXYWH, pixmap, x, y, "psinok ", "%3ld", midelta (psinok));
y += fheight;
disp_info_long (window, display, gc, DrawAreaXYWH, pixmap, x, y, "rsout ", "%3ld", midelta (rsout));
y += fheight;
disp_info_long (window, display, gc, DrawAreaXYWH, pixmap, x, y, "rsin ", "%3ld", midelta (rsin));
y += fheight;
#endif
y += fheight;
disp_info_int (window, display, gc, DrawAreaXYWH, x, y, pixmap, "pages from ", "", 0);
y += fheight;
disp_info_long (window, display, gc, DrawAreaXYWH, pixmap, x, y, "swap ", "%5ld", midelta (swap));
y += fheight;
disp_info_long (window, display, gc, DrawAreaXYWH, pixmap, x, y, "cache ", "%5ld", midelta (cache));
y += fheight;
disp_info_long (window, display, gc, DrawAreaXYWH, pixmap, x, y, "file ", "%5ld", midelta (file));
y += fheight;
} /* end of update_Sysinfo */
/*+-------------------------------------------------------------------------
draw_Sysinfo_literals(x,y,scale_name,val1_name,val2_name,val3_name)
--------------------------------------------------------------------------*/
void
draw_Sysinfo_literals (SP)
struct NetworkXswStruct *SP;
{
Window window = SP -> SEPERATE_WINDOWS_LIST[BUTTON_sysinfo].window;
Display *display = SP -> SEPERATE_WINDOWS_LIST[BUTTON_sysinfo].display;
GC gc = SP -> SEPERATE_WINDOWS_LIST[BUTTON_sysinfo].gc;
XWindowAttributes DrawAreaXYWH = SP -> SEPERATE_WINDOWS_LIST[BUTTON_sysinfo].DrawAreaXYWH;
Pixmap pixmap = SP -> SEPERATE_WINDOWS_LIST[BUTTON_sysinfo].pixmap;
int x = 0;
int y = 0;
int x2 = x;
int ys = y + FASCENT;
int yl1 = y + (FASCENT / 2) + 1;
int yl2 = y + (FHEIGHT / 2);
int len;
char *cptr;
int fheight = FHEIGHT;
int fwidth = FWIDTH;
int line_style = LineSolid;
int cap_style = CapButt;
int join_style = JoinMiter;
sysinfo_tlx = x;
sysinfo_tly = y;
/* the "background" color */
XSetForeground (display, gc, colorTitleBarBG.pixel);
XSetLineAttributes (display, gc, fheight,
line_style, cap_style, join_style);
/*
XDrawLine (display, window, gc, x, yl2, DrawAreaXYWH.width - BORDER_EXTRA_WIDTH , yl2);
*/
XDrawLine (display, pixmap, gc, x, yl2, SP -> SEPERATE_WINDOWS_LIST[BUTTON_sysinfo].width - BORDER_EXTRA_WIDTH, yl2);
/* "-----Sysinfo/Minfo-----------------" */
XSetForeground (display, gc, colorTitleBarFG.pixel);
XSetLineAttributes (display, gc, FASCENT / 2,
line_style, cap_style, join_style);
/*
XDrawLine (display, window, gc,
x2, yl1,
x2 + (len = (fwidth * 5)) - FGAP, yl1);
*/
XDrawLine (display, pixmap, gc,
x2, yl1,
x2 + (len = (fwidth * 5)) - FGAP, yl1);
x2 += len;
cptr = "Sysinfo/Minfo";
/*
XDrawString (display, window, gc, x2, ys, cptr, len = strlen (cptr));
XDrawString (display, window, gc, x2 + 1, ys, cptr, len);
*/
XDrawString (display, pixmap, gc, x2, ys, cptr, len = strlen (cptr));
XDrawString (display, pixmap, gc, x2 + 1, ys, cptr, len);
x2 += (fwidth * len) + FGAP + 1;
/*
XDrawLine (display, window, gc, x2, yl1, DrawAreaXYWH.width - BORDER_EXTRA_WIDTH , yl1);
*/
XDrawLine (display, pixmap, gc, x2, yl1, SP -> SEPERATE_WINDOWS_LIST[BUTTON_sysinfo].width - BORDER_EXTRA_WIDTH, yl1);
} /* end of draw_Sysinfo_literals */
/* vi: set tabstop=4 shiftwidth=4: */
/* end of sysinfo.c */